<%@ page language="java" %>
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="com.sisuntech.common.*" %>
<%@ page import="com.sisuntech.org.*" %>
<%
  String md5_code = "5848201314";
  String sso_service = "http://59.151.61.23/boss/systemBase/sso_service.jsp";
  String sso_login = "http://59.151.61.23/boss/systemBase/login.jsp";
  String sso_sync = "http://" + request.getServerName();
  if(80 != request.getServerPort())sso_sync += ":" + request.getServerPort();
  sso_sync += request.getContextPath();
  sso_sync += "/systemBase/sso_sync.jsp";

  String sso_status = "0";
  String nextUrl = request.getParameter("nextUrl");
  String md5 = request.getParameter("md5");

  if(md5 != null)
  {
    sso_status = "1";
    String loginName = CommonUtil.webToGb(request.getParameter("loginName"));
    String cur_md5 = StringUtil.hash(loginName + md5_code);
    if(!"".equals(loginName) && cur_md5.equals(md5))
    {
      UserBase curUser = new UserBase();
      curUser.setLoginName(loginName);
      if(curUser.load())
      {
        request.getSession().setAttribute(AppConstants.Session_User, curUser);
        sso_status = "2"; 
      }  
    }
  }
  
  String toUrl = sso_login;
  if("0".equals(sso_status))
  {
    toUrl = sso_service + "?site_from=" + sso_sync + "&nextUrl=" + nextUrl;
  }  
  else if("2".equals(sso_status))
  {
    toUrl = StringUtil.replace(nextUrl, "@", "&");
  }  
  //System.out.println(toUrl);
  response.sendRedirect(toUrl);
%>

